/*    */ package com.qmsk.business.info.group.controller;
/*    */ 
/*    */ import com.qmsk.business.info.group.dao.GroupDAO;
/*    */ import com.utils.gson.in.GsonHeadOneRow;
/*    */ import com.utils.gson.out.GsonEbRst;
/*    */ import com.utils.jdbc.connection.DbConnection;
/*    */ import com.utils.web.RequestUtils;
/*    */ import com.utils.web.ResponseUtils;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.transaction.annotation.Transactional;
/*    */ import org.springframework.web.bind.annotation.PathVariable;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"/group"})
/*    */ public class GroupController
/*    */ {
/* 27 */   private static final Logger logger = Logger.getLogger(GroupController.class);
/*    */ 
/*    */   @Autowired
/*    */   private GroupDAO dao;
/*    */ 
/*    */   @RequestMapping(value={"find/all/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public void getListOfAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*    */   {
/* 35 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*    */     try {
/* 37 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(nPageIdx, nPageSize);
/* 38 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*    */     } catch (SQLException e) {
/* 40 */       ResponseUtils.setErrorMsgResponse("查询集团出错", response);
/* 41 */       logger.error(e);
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void insert(HttpServletRequest request, HttpServletResponse response) {
/* 48 */     String sGsonInData = request.getParameter("data");
/*    */     try
/*    */     {
/* 51 */       int nResult = this.dao.insertJsonOneRow(sGsonInData);
/* 52 */       DbConnection.commit();
/* 53 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 54 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 55 */         response);
/*    */     } catch (Exception e) {
/* 57 */       DbConnection.rollback();
/* 58 */       logger.error(e);
/* 59 */       ResponseUtils.setErrorMsgResponse("插入集团出错:" + e.getMessage(), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping({"edit"})
/*    */   public void update(HttpServletRequest request, HttpServletResponse response) {
/*    */     try {
/* 67 */       String id = RequestUtils.getString(request, "id");
/* 68 */       String sGsonInData = request.getParameter("data");
/* 69 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 70 */       if (g == null) {
/* 71 */         ResponseUtils.setErrorMsgResponse(RequestUtils.getReadJsonDataErrorMessage(request), response);
/*    */       } else {
/* 73 */         int nResult = this.dao.updateJsonOneRow(g, id);
/* 74 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 75 */           RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request), 
/* 76 */           response);
/*    */       }
/* 78 */       DbConnection.commit();
/*    */     } catch (Exception e) {
/* 80 */       DbConnection.rollback();
/* 81 */       logger.error(e);
/* 82 */       ResponseUtils.setErrorMsgResponse("修改集团资料出错:" + e.getMessage(), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void delete(HttpServletRequest request, HttpServletResponse response) {
/* 89 */     String id = RequestUtils.getStringOfId(request);
/*    */     try {
/* 91 */       String[] strParams = id.split(",");
/* 92 */       int nResult = this.dao.deleteParams(strParams);
/* 93 */       DbConnection.commit();
/* 94 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 95 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 96 */         response);
/*    */     } catch (Exception e) {
/* 98 */       DbConnection.rollback();
/* 99 */       logger.error(e);
/* 100 */       ResponseUtils.setErrorMsgResponse("删除集团出错:" + e.getMessage(), response);
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.group.controller.GroupController
 * JD-Core Version:    0.5.3
 */